<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router';

import { useUserStore } from '@/stores/user';
import { uploadTaskEventToGA, getAssetsFiles } from '@/utils'
import { uploadTaskEventToAdmin } from '@/api/task';

import BiBootPopup from '@/components/bi-boot-popup/index.vue'

defineOptions({
    name: 'BiInvited'
})
const router = useRouter()
const userStore = useUserStore()

const showBootPopup = ref(false)
const openBootPopup = () => {
    showBootPopup.value = true
}
const handlerToInvitedPage = () => {
    uploadTaskEventToGA('点击邀请素材')
    uploadTaskEventToAdmin({
        device: userStore.device,
        moduleType: 3,
        eventType: 31
    })
    if (typeof android !== 'undefined' && android.getAppVersion) {
        router.push('./invited')
    } else {
        openBootPopup()
    }
}
</script>

<template>
    <div class="invited" @click="handlerToInvitedPage">
        <img class="invited_img" v-lazy="getAssetsFiles('invited.png')" alt="invited" width="350">
        <img class="invited_button" v-lazy="getAssetsFiles('button.png')" alt="invited_btn" width="100">
    </div>

    <BiBootPopup v-model:show="showBootPopup" />
</template>

<style scoped lang="scss">
@import url(./index.scss);
</style>